<template>
    <div id="mapPage" class="mapPage">
      <hi @click="testStore">{{msg}}</hi>
      <div v-for="(item,i) in store.state.gushiList" :key="i">
        <p>
          {{item[0]}}===>{{item[1]}}
        </p>
      </div>
    </div>
</template>

<script>

import store from "../store/index.js";
import axios from 'axios';

export default {
  name: "Test.vue",
  data(){
    return{
      msg:0
    }
  },
  methods:{
    /*调用store state中的方法*/
    testStore:function (){
      this.msg=this.store.state.message
    }
  },
  provide:{
    store
  },
  setup() {
    // fetch(api).then(res=>res.json()).then(result=>{
    //   store.setList(result.result)
    //   console.log(result)
    // })
    axios.get(api).then(result=>{
      console.log(result)
      store.commit('setList',result.data)
    });
    let api1=store.state.dbApi
    axios.post(api1,'张三').then(result=>{
      console.log(result.data)
      store.commit('setList',result.data)
    }).catch((err)=>{console.log(err)});
    return{
      store
    }
  },
}
</script>

<style scoped>

</style>